<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateChatGroupHistoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chat_group_history', function (Blueprint $table) {
            $table->id();
            $table->string('clientMsgId', 32)->default('')->comment('客户端传入的消息id');
            $table->unsignedInteger('groupId')->default(0)->comment('群聊id');
            $table->unsignedInteger('shopId')->default(0)->comment('门店id');
            $table->unsignedInteger('sessionId')->default(0)->comment('会话id');
            $table->unsignedInteger('senderUid')->default(0)->comment('发送人id 0默认为系统');
            $table->text('content')->default('')->comment('消息内容');
            $table->string('type', 16)->default('')->comment('消息类型 text/images/lists/tips');
            $table->tinyInteger('recall')->default(0)->comment('撤销状态 0否 1被撤销');
            $table->unsignedInteger('recallUid')->default(0)->comment('撤销人id');
            $table->tinyInteger('sensitive')->default(0)->comment('触发敏感词');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '群聊 - 聊天记录';

            $table->index(['clientMsgId'], 'idx_clientMsgId');
            $table->index(['sessionId'], 'idx_sessionId');
            $table->index(['groupId'], 'idx_groupId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('chat_group_history');
    }
}
